<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/
include_once('Admin.php');
if($WebStaticHTML != 1){
	die('您没有开通HTML静态功能，请在系统全局设定中开通后进入该页。<a href="HtmlMake.php">刷新</a>');
}
//清空所有静态文件
if($_GET['a'] == 'delall'){
	if(@removeDir('../html/') && @unlink('../home.html')){
		@mkdir('../html'); @chmod ('../html',0777);
	} 
	MsgBox(1,'操作成功。',"HtmlMake.php?Lang={$Lang}");
}
//清空缓存、编译、退出前台登录、清空配置文件
if(!empty($_GET['Action'])){
	//环境检测
	if(!get_cfg_var("allow_url_fopen") && !extension_loaded('curl')){
		MsgBox(1,'您的服务器不支持 file_get_contents 函数，无法完成请求。','-1');
	}
	setcookie('isLogin','',1,"/");
	if(!@file_put_contents('../config/htmlpage.php','<!--//-->')) MsgBox(1,'修改配置文件失败，没有写入权限：../config/htmlpage.php','-1');
	
	function DateToID($table,$text,$toUrlAction){
		global $_GET,$dbprefix,$db,$Lang;
		$SQL = "SELECT `ID` FROM `{$dbprefix}" . strtolower($table) . "` WHERE `{$table}Lang` = {$Lang} && `{$table}Audit` = 1 && `{$table}Time` >= '{$_GET['Date1']}' ORDER BY `ID` ASC LIMIT 0,1";
		$StartID = $db -> SelectSQL($SQL,0);
		$StartID = $StartID[0][0];
		$Date2 = date('Y-m-d',strtotime($_GET['Date2'])+86400); //24h
		$SQL = "SELECT `ID` FROM `{$dbprefix}" . strtolower($table) . "` WHERE `{$table}Lang` = {$Lang} && `{$table}Audit` = 1 && `{$table}Time` <= '{$Date2}' ORDER BY `ID` DESC LIMIT 0,1";
		$EndID = $db -> SelectSQL($SQL,0);
		$EndID = $EndID[0][0];
		if(is_numeric($StartID) && is_numeric($EndID)){
			MsgBox(0,'',"HtmlMake.php?Action={$toUrlAction}&Lang={$Lang}&StartID={$StartID}&EndID={$EndID}");
		} else {
			MsgBox(1,"在指定的日期内没有查询到相关{$text}。","HtmlMake.php?Lang={$Lang}");
		}		
	}
	
	if($_GET['Action'] == 'isDate'){
		switch ($_GET['type']){ 
			case 1:
				DateToID('Product','产品','Product');
				break;
			case 2:
				DateToID('News','新闻','News');
				break;
			case 3:
				DateToID('Article','内容','Page');
				break;				
		}	
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
<script src="../js/selectdate.js" type="text/javascript"></script>
<style type="text/css">
a.But:link, a.But:visited{display:block; margin:10px; width:128px; height:34px; font-size:13px; font-family:Arial; line-height:34px; text-align:center; color:black; text-decoration:none; background:url('images/background.gif') no-repeat;}
a.But:hover, a.But:active{background:url('images/background-hover.gif') no-repeat; color:white;}
</style>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr class="Notodd"><td><?php TopLang();?></td><td align="right"><input type="button" style="width:120px; height:25px;" value="清空所有静态文件" onClick="javascript:location.href='HtmlMake.php?a=delall&Lang=<?php echo $Lang;?>'"></td></tr>
</table>
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td align="center" class="Main_Title">生成HTML静态文件<?php echo $OnWebLangName?></td>
  </tr>
	<tr>
	<td bgcolor="#FFFFFF" align="center">
		<table>
		  <tr>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=Home&Lang=<?php echo $Lang?>" class="But">生成网站首页文件</a></td>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=Basic&Lang=<?php echo $Lang?>" class="But">生成所有模块首页</a></td>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=ProductColumn&Lang=<?php echo $Lang?>" class="But">产品首页及栏目页</a></td>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=Product&Lang=<?php echo $Lang?>" class="But">生成所有产品内页</a></td>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=All&Lang=<?php echo $Lang?>" class="But"><font color="#0000FF">一键生成整个网站</font></a></td>
		  </tr>
		<tr>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=Page&Lang=<?php echo $Lang?>" class="But">生成内容文章内页</a></td>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=NewsColumn&Lang=<?php echo $Lang?>" class="But">新闻首页及栏目页</a></td>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=News&Lang=<?php echo $Lang?>" class="But">生成所有新闻内页</a></td>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=DownloadColumn&Lang=<?php echo $Lang?>" class="But">下载首页及栏目页</a></td>
			<td align="center" bgcolor="#FFFFFF"><a href="HtmlMake.php?Action=Other&Lang=<?php echo $Lang?>" class="But">会员注册及其它页</a></td>
		  </tr>
		</table>
	</td>
  </tr>
  <tr>
  	<td bgcolor="#FFFFFF" align="center">
		<table>
		<form action="HtmlMake.php" method="get" name="Date">
			<tr>
				<td bgcolor="#FFFFFF" height="40">按发表日期生成：</td>
				<td bgcolor="#FFFFFF">生成由</td>
				<td bgcolor="#FFFFFF">
					<input name="Date1" id="Date1" type="text" onClick="javascript:showcal(this)" value="<?php echo date('Y-m-d');?>" size="10" readonly="readonly" style="color:#F00;">
					<a href="javascript:showcal(document.getElementById('Date1'));"><img src="images/SelectDate.gif" width="17" height="16" border="0" /></a>
				</td>
				<td bgcolor="#FFFFFF">至</td>
				<td bgcolor="#FFFFFF">
					<input name="Date2" id="Date2" type="text" onClick="javascript:showcal(this)" value="<?php echo date('Y-m-d');?>" size="10" readonly="readonly" style="color:#F00;">
					<a href="javascript:showcal(document.getElementById('Date2'));"><img src="images/SelectDate.gif" width="17" height="16" border="0" /></a>
				</td>
				<td bgcolor="#FFFFFF">之间发布的所有</td>
				<td bgcolor="#FFFFFF"><select name="type">
					<option value="1">产品</option>
					<option value="2">新闻</option>
					<option value="3">内容</option>
				</select></td>
				<td bgcolor="#FFFFFF">内页</td>
				<td bgcolor="#FFFFFF">
					<input type="hidden" name="Lang" value="<?php echo $Lang;?>" />
					<input type="hidden" name="Action" value="isDate" />
					<input value=" 开始 " type="submit" />
				</td>
			</tr>
		</form>
		</table>
	</td>
  </tr>
<?php if (!get_cfg_var("allow_url_fopen") && !extension_loaded('curl')){?> 
	<tr>
		<td align="center" bgcolor="#FFFFFF" style="color:#333333; font-size:13px; line-height:30px;">
		您的服务器不支持 file_get_contents 函数，无法使用静态功能。<br />
		请修改 php.ini 配置文件，将 <font color="#FF0000">allow_url_fopen = Off</font> 修改为 <font color="#FF0000">allow_url_fopen = On</font><br />
		或者启用 CURL 扩展：去掉 <font color="#FF0000">;extension=php_curl.dll</font> 前面的分号。<br />
		以上两种方法，请选择其中任意一种设置。
		</td>
	</tr> 
<?php } elseif(!empty($_GET['Action'])) {?>
	<tr>
		<td align="center" bgcolor="#FFFFFF">
			<table>
				<tr><td height="30" align="center" valign="middle" bgcolor="#FFFFFF" id="wait" style="font-size:13px; color:#363;"><a title="强行中止页面生成" href="HtmlMake.php?Lang=<?php echo $Lang?>"><img alt="强行中止生成" src="images/wait.gif" width="280" height="13" border="0" /></a></td></tr>
				<tr><td height="60" valign="middle" bgcolor="#FFFFFF"><iframe src="./HtmlMakeSub.php?<?php echo $_SERVER['QUERY_STRING'];?>" width="600" height="90" scrolling="no" frameborder="0"></iframe></td></tr>
			</table>
		</td>
	</tr> 
<?php }?>	
  </table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
	<tr class="Notodd">
		<td style="color:#333333; line-height:20px;">
注：1、生成过程中请勿刷新或关闭该页。<br />
　　2、生成过程中点击滚动条可强行中止进程。<br />
　　3、生成过程中如果出现超时或URL错误等信息请在全局设定中调整"批量生成HTML间隔时间"。<br />
		</td>
	</tr>
</table>  
</body>
</html>
